package com.pctx.bibatracker.controller;

import com.pctx.bibacommon.result.Result;
import com.pctx.bibatracker.service.FenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/fence")
public class FenceController {
    @Autowired
    private FenceService fenceService;

    /**
     * 添加围栏（百度坐标）
     *
     * @param deviceNo
     * @param address
     * @param radius
     * @param fence_name
     * @return
     * @throws Exception
     */
    @RequestMapping("/addFence")
    public Result addFence(String deviceNo, String address, Long radius, String fence_name,String type) throws Exception {
        return fenceService.addFence(deviceNo, address, radius, fence_name,type);
    }

    /**
     * 围栏列表
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/selectFence")
    public Result selectFence(String deviceNo) throws Exception {
        return fenceService.selectFence(deviceNo);
    }

    /**
     * 添加围栏（高德坐标）
     *
     * @param deviceNo
     * @param address
     * @param radius
     * @param fence_name
     * @return
     * @throws Exception
     */
    @RequestMapping("/addGaodeFence")
    public Result addGaodeFence(String deviceNo, String address, Long radius, String fence_name) throws Exception {
        return fenceService.addGaodeFence(deviceNo, address, radius, fence_name);
    }

    /**
     * 删除围栏
     * @param deviceNo
     * @param fence_name
     * @return
     * @throws Exception
     */
    @RequestMapping("/deleteFence")
    public Result deleteFence(String deviceNo, String fence_name) throws Exception {
        return fenceService.deleteFence(deviceNo, fence_name);
    }
}
